﻿using UnityEngine;
using System;
using System.Collections;

public class DefaultBossListCell : MonoBehaviour
{
	[HideInInspector] public int indexPath;
	
	public UILabel bossNameLabel;
	public UILabel finderNameLabel;
	public UISlider hpSlider;
	public UILabel remainTimeLabel;
	public GameObject entranceButton;

	DateTime endDateTime;
	TimeSpan remainTimeSpan;

	public IEnumerator RemainTimeTimer(long dateTimeGap)
	{
		DateTime startDateTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
		endDateTime = startDateTime.AddMilliseconds(dateTimeGap).ToLocalTime();

		while(true)
		{
			remainTimeSpan = endDateTime - DateTime.Now;
			if(remainTimeSpan.TotalSeconds > 0)
			{
				remainTimeLabel.text = string.Format("{0:00}:{1:00}:{2:00}", remainTimeSpan.Hours, remainTimeSpan.Minutes, remainTimeSpan.Seconds);
				yield return new WaitForSeconds(1.0f);
			}
			// 시간 초과했을 경우
			else
			{
				remainTimeLabel.text = "[FF0000]00:00:00";
				NGUITools.SetActive(entranceButton, false);
				yield break;
			}
			

		}
	}

	public void OnClick_SelectRaidBoss()
	{
		this.GetComponent<UIDragScrollView>().scrollView.GetComponent<DefaultBossListScrollView>().sceneManager.OnClick_SelectRaidBoss(indexPath);
	}
}